﻿using Live.Core.Douyin;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    internal class Program
    {
        private static async Task Main(string[] args)
        {
            var arguments = "-i \"http://pull-flv-l13.douyincdn.com/third/stream-405918017286308627_or4.flv?arch_hrchy=h1&exp_hrchy=h1&expire=1754290676&major_anchor_level=common&sign=ee212f7309b826c542e26718e78eb8be&t_id=037-20250728145756029D6A131B7AB50E08AB-fI7cxH&unique_id=stream-405918017286308627_787_flv_or4\" -c copy -f mp4 \"C:\\Users\\DELL\\Documents\\TangLiveRecorder\\Recordings\\颜颜???唱歌不美颜_20250728_145756.mp4\"";
            // 创建进程启动信息
            var startInfo = new ProcessStartInfo
            {
                FileName = "ffmpeg",
                Arguments = arguments,
                UseShellExecute = false,  // 不使用操作系统外壳程序启动
                RedirectStandardOutput = true,  // 重定向标准输出
                RedirectStandardError = true,   // 重定向标准错误
                CreateNoWindow = true,   // 不创建窗口
                StandardOutputEncoding = Encoding.UTF8,
                StandardErrorEncoding = Encoding.UTF8
            };
            var process = new Process { StartInfo = startInfo };
            // 启动进程
            process.Start();

            // 异步读取输出，避免死锁
            var outputTask = process.StandardOutput.ReadToEndAsync();
            var errorTask = process.StandardError.ReadToEndAsync();
        }
    }
}